﻿using System.Drawing;
using System.Windows.Forms;

namespace Expense_Tracker_System
{
    public partial class zOptionsForm : Form
    {
        aHelperModule helpModule = new aHelperModule();

        public zOptionsForm()
        {
            InitializeComponent();
        }

        private void zOptionsForm_Load(object sender, System.EventArgs e)
        {
            helpModule.LoadCheckBoxes(cbTray, cbMaximize, cbRunStart);
            btnAddValue.Enabled = false;
        }

        private void btnOK_Click(object sender, System.EventArgs e)
        {
            helpModule.SaveSettings(cbTray);
            helpModule.SaveSettings(cbMaximize);
            helpModule.SaveSettings(cbRunStart);
            this.Close();
        }

        private void btnCheckValue_Click(object sender, System.EventArgs e)
        {
            if (txtbxExpenseType.Text != "")
            {
                if (helpModule.CheckTypes(txtbxExpenseType.Text) == true)
                {
                    lblCheckStatus.Text = "Expense Type Not Exist.";
                    lblCheckStatus.ForeColor = Color.Green;
                    btnAddValue.Enabled = true;
                }
                else
                {
                    lblCheckStatus.Text = "Expense Type Exist.";
                    lblCheckStatus.ForeColor = Color.Red;
                    btnAddValue.Enabled = false;
                }
            }
            else
            {
                lblCheckStatus.Text = "Expense Type Blank.";
                lblCheckStatus.ForeColor = Color.Red;
                btnAddValue.Enabled = false;
            }
            
        }

        private void btnAddValue_Click(object sender, System.EventArgs e)
        {
            string expenseTypeValue = txtbxExpenseType.Text.Trim();
            if (helpModule.SaveTypes(expenseTypeValue) == 1)
            {
                lblCheckStatus.Text = "Expense Type Saved.";
                lblCheckStatus.ForeColor = Color.Green;
                txtbxExpenseType.Text = "";
            }
            else
            {
                lblCheckStatus.Text = "Expense Type Failed.";
                lblCheckStatus.ForeColor = Color.Red;
            }
            btnAddValue.Enabled = false;
        }

    }
}
